package com.bw.controller;


import com.bw.config.ExportUserUtils;
import com.bw.entity.Esvo;
import com.bw.entity.Users;
import com.bw.entity.Vo;
import com.bw.service.impl.UsersServiceImpl;
import org.apache.catalina.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.BoundGeoOperations;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.web.bind.annotation.*;

import java.util.ArrayList;
import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author 王墨
 * @since 2021-11-05
 */
@RestController
@RequestMapping("/users")
@CrossOrigin
public class UsersController {

    @Autowired
    private UsersServiceImpl usersService;





    @GetMapping("/daochu")
    public  void main1() {

       List<Users> list = usersService.list();
       String path="D:/user.xls";
        //导出
        ExportUserUtils.exportUser(list,path);
    }

    @RequestMapping("/ulist")
    public List<Users> ulist(@RequestBody Vo vo){
        return usersService.ulist(vo);
    }

    @RequestMapping("/list")
    public List<Users> list(){
        return usersService.list();
    }

    @PostMapping("/uadd")
    public int uadd(@RequestBody Users users){

        return usersService.uadd(users);
    }

    @PostMapping("/uset/{userId}")
    public int uset(@RequestBody Users users){

        return usersService.uset(users);
    }

    @PostMapping("/hx/{userId}")
    public Users hx(@PathVariable("userId")int userId){
        return usersService.hx(userId);
    }



    @PostMapping("/del/{userId}")
    public int udel(@PathVariable("userId")int userId){

        return usersService.udel(userId);
    }

    @RequestMapping("/relist")
    public List<Users> relist(){
        return usersService.relist();
    }

    @RequestMapping("/uplist")
    public String uplist(){
        return usersService.uplist();
    }

    @RequestMapping("/eslist")
    public List<Users> eslist(@RequestBody Esvo esvo){
        return usersService.eslist(esvo);
    }

}
